<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>树形菜单局</title>
		<script type="text/javascript" src="../js/jquery-1.8.3.js"></script>
		<script type="text/javascript" src="../js/easyui/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../js/easyui/locale/easyui-lang-zh_CN.js"></script>
		<link rel="stylesheet" href="../js/easyui/themes/default/easyui.css" />
		<link rel="stylesheet" href="../js/easyui/themes/icon.css" />
		<!--Ztree-->
		<script type="text/javascript" src="../js/ztree/jquery.ztree.all-3.5.js"></script>
		<link rel="stylesheet" href="../js/ztree/zTreeStyle.css" />
		<script type="text/javascript">
			$(function() {
				$("#czbk").click(function() {
					$('#mytabs').tabs('add', {
						title: '传智播客',
						selected: false
					});
				});

				var setting = {
					data: {
						simpleData: {
							enable: true // 支持简单json数据格式
						}
					},
					callback: {
						onClick: function(event, treeId, treeNode, clickFlag) {

							var content = "<div style='width:100%;height:100%;overflow:hidden'>" +
								"<iframe src='" + treeNode.page + "' scrollint='auto' style='width:100%;height:100%;border:0'></iframe></div>"
							// 没有page树形菜单，不打开选项卡
							if(treeNode.page != undefined && treeNode.page != "") {
								/*判断此面板是否已经打开*/
								if($("#mytabs").tabs('exists', treeNode.name)) {
									/*如果打开了此面板则选中*/
									$("#mytabs").tabs('select', treeNode.name);
								} else {
									/*没有打开的话添加此选项卡*/
									$("#mytabs").tabs('add', {
										title: treeNode.name,
										content: content,
										closable: true
									});
								}
							}
						}
					}
				};

				/*节点*/
				var nodes = [{
						id: 1,
						pId: 0,
						name: "父节点1"
					},
					{
						id: 11,
						pId: 1,
						name: "子节点1"
					},
					{
						id: 12,
						pId: 1,
						name: "子节点2"
					},
					{
						id: 2,
						pId: 0,
						name: "父节点1"
					},
					{
						id: 13,
						pId: 2,
						name: "传智",
						page: "https://www.baidu.com/"
					},
					{
						id: 14,
						pId: 2,
						name: "黑马",
						page: "http://www.cnki.net/"
					}
				]
				$.fn.zTree.init($("#baseMenu"), setting, nodes);
				/*窗口*/
				$("#mytabs").tabs({
					onContextMenu: function(e, title,index){
						// 阻止默认菜单显示
						e.preventDefault();
						
						// 显示自定义右键菜单
						$("#mm").menu('show',{
							left : e.pageX,
							top : e.pageY
						});
					}
				});
			});
		</script>
	</head>

	<body class="easyui-layout">

		<div data-options="region:'north',title:'传智播客中心',split:true" style="height:130px;"></div>

		<div data-options="region:'south',split:true" style="height:100px;"></div>

		<div data-options="region:'east',split:true" style="width:100px;"></div>

		<div data-options="region:'west',split:true,title:'菜单导航'" style="width:180px;">
			<div id="aa" class="easyui-accordion" data-options="fit:true">

				<div title="基楚菜单">
					<a href="javascript:void(0)" id="czbk">传智播客</a>

				</div>
				<div title="系统菜单">
					<ul id="baseMenu" class="ztree"></ul>
				</div>
			</div>
		</div>

		<div data-options="region:'center'">
			<div id="mytabs" class="easyui-tabs" data-options="fit:true">
				<!--<div title="传智1" data-options="closable:true">tab1 </div>
				<div title="传智2" data-options="closable:true">tab2 </div>
				<div title="传智3" data-options="closable:true">tab3 </div>-->
			</div>
			
		<!-- 菜单 初始化都是隐藏的-->
		<div id="mm" class="easyui-menu" style="width:120px;">
			<div>关闭当前窗口</div>
			<div>关闭其它窗口</div>
			<div class="menu-sep"></div>  <!-- 分隔线 -->
			<div data-options="iconCls:'icon-cancel'">关闭全部窗口</div>
		</div>	

			
		</div>

	</body>

</html>